package service

import (
	"go-malphite/app/common/enum"
	"go-malphite/app/model"
	"go-malphite/app/utils"
)

// FindRoleById 根据id获取角色
func FindRoleById(id int64) (model.Role, error) {
	role := model.Role{}
	err := utils.DB.Where("role_id = ?", id).First(&role).Error
	if err != nil {
		return role, err
	}
	return role, nil
}

func FindRoleByType(t enum.RoleTypeEnum) (model.Role, error) {
	role := model.Role{}
	err := utils.DB.Where("role_type = ?", t.Get()).First(&role).Error
	if err != nil {
		return role, err
	}
	return role, nil
}
